package cn.elead.chaos.email.controller;

import javax.mail.MessagingException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.elead.chaos.email.domain.CustomMailMessage;
import cn.elead.chaos.email.service.IEmailService;

@RestController
@RequestMapping("/mail")
public class MailController {

	@Autowired
	private IEmailService emailService;

	/**
	 * 纯文本格式
	 * 
	 * @return
	 * @throws MessagingException 
	 */
	@PostMapping("/html")
	public CustomMailMessage sendHtmlMail(@RequestBody CustomMailMessage message) throws MessagingException {
		return emailService.sendHtmlMail(message);
	}

	/**
	 * 附件格式
	 * 
	 * @return
	 */
	@PostMapping("/attach")
	public CustomMailMessage sendAttachmentsMail(@RequestBody CustomMailMessage message) throws MessagingException {
		return emailService.sendAttachmentsMail(message);
	}
}
